home *** CD-ROM | disk | FTP | other *** search
- #include "PICS_Utils.h"
- #include "PICS_Types.h"
-
- #include "PICS_Operations.h" // For error-codes
- #include "SimpleError.h"
- #include "assert_mac.h"
-
- #include <ImageCompression.h> // For StandardGetFilePreview()
- #include <PictUtils.h> // For GetPictInfo()
- #include <Gestalt.h>
-
- // ---------------------------------------------------------------------------
-
- Boolean OpenPICSFile(FSSpec *file) {
- StandardFileReply reply;
- SFTypeList typeList;
- long info;
- Boolean hasPreview;
-
- ASSERT(file != NULL);
-
- Gestalt(gestaltQuickTime, &info);
- if (info > 0)
- hasPreview = true;
- else
- hasPreview = false;
-
- typeList[0] = kPICSFileType1;
- typeList[1] = kPICSFileType2;
-
- if (hasPreview)
- StandardGetFilePreview(NULL, 2, typeList, &reply);
- else
- StandardGetFile(NULL, 2, typeList, &reply);
-
- if (reply.sfGood) {
- *file = reply.sfFile;
- return(true);
- }
- else
- return(false);
- } // END OpenPICSFile
-
- // ---------------------------------------------------------------------------
-
- Boolean OpenPICTFile(FSSpec *file) {
- StandardFileReply reply;
- SFTypeList typeList;
- long info;
- Boolean hasPreview;
-
- Gestalt(gestaltQuickTime, &info);
- if (info > 0)
- hasPreview = true;
- else
- hasPreview = false;
-
- ASSERT(file != NULL);
-
- typeList[0] = kPICTFileType;
-
- if (hasPreview)
- StandardGetFilePreview(NULL, 1, typeList, &reply);
- else
- StandardGetFile(NULL, 1, typeList, &reply);
-
- if (reply.sfGood) {
- *file = reply.sfFile;
- return(true);
- }
- else
- return(false);
- } // END OpenPICTFile
-
- // ===========================================================================
-
- Boolean FetchPICSFileInfo(
- const FSSpec *file, // Input
- Rect *picsRect, // Output
- short *picsDepth, // Output
- short *numFrames) { // Output
-
- short fileRefNum;
- short numOfFrames;
- PicHandle thePic;
-
- fileRefNum = FSpOpenResFile(file, fsRdWrPerm);
- if (fileRefNum == -1) {
- SimpleError(kAlertErrID, kErrMsgID, kCantOpenFileErrMsg);
- return(false);
- }
- UseResFile(fileRefNum);
-
- numOfFrames = Count1Resources(kPICSRsrcType);
- if (numOfFrames < 1) {
- SimpleError(kAlertErrID, kErrMsgID, kNoPICTsInFileErrMsg);
- return(false);
- }
- *numFrames = numOfFrames;
-
- thePic = (PicHandle)Get1Resource(kPICSRsrcType, kPICSRsrcStartID);
- if (thePic == NULL) {
- SimpleError(kAlertErrID, kErrMsgID, kInvalidPICSFormatErrMsg);
- return(false);
- }
-
- *picsRect = (**thePic).picFrame;
- *picsDepth = GetPictDepth(thePic);
-
- ReleaseResource((Handle)thePic);
- CloseResFile(fileRefNum);
- return(true);
- } // END FetchPICSFileInfo
-
- // ---------------------------------------------------------------------------
-
- short GetPictDepth(PicHandle thePic) {
- PictInfo pictInfo;
- OSErr myErr;
-
- myErr = GetPictInfo(thePic, &pictInfo, returnPalette,
- 1, systemMethod, 0);
-
- if (myErr == noErr) {
- return(pictInfo.depth);
- }
- else {
- SimpleError(kAlertErrID, kErrMsgID, kCantGetPictInfoErrMsg);
- return(0);
- }
- } // END GetPictDepth